<template>
  <div class="cu-common-layout">
    <div class="cu-common-layout-center">
      <el-row class="cu-common-search-box" :gutter="16">
        <el-form @submit.native.prevent>
          <el-col :span="6">
            <el-form-item label="校区品牌" prop="brand">
              <el-select v-model="query.brand" placeholder="" clearable :style="{ width: '100%' }">
                <el-option :key="item.id" :label="item.fullName" :value="item.enCode" v-for="item in brandOptions" />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="校区区域" prop="provinceId">
              <custom-address v-model="query.provinceId" placeholder="" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="校区信息" prop="info">
              <el-input v-model="query.info" :style="{ width: '100%' }"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
              <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div class="cu-common-layout-main cu-flex-main">
        <div class="cu-common-head">
          <div class="cu-common-head-left">
            <el-button type="primary" icon="el-icon-plus" @click="addBatchOrUpdateHandle()">批量积分</el-button>
            <el-button type="text" icon="el-icon-plus" @click="ImportFormHandle()">导入</el-button>
            <el-button v-has="'btn_download'" type="text" icon="el-icon-download" @click="exportData()">导出</el-button>
          </div>
          <div class="cu-common-head-right">
            <el-tooltip effect="dark" content="刷新" placement="top">
              <el-link icon="icon-ym icon-ym-Refresh cu-common-head-icon" :underline="false" @click="reset()" />
            </el-tooltip>
            <screenfull isContainer />
          </div>
        </div>
        <custom-table v-loading="listLoading" ref="checked-table" :data="list" @ranking-change="sortChange" :hasC="true" @selection-change="handleSelectionChange" :default-ranking="{ prop: 'ranking', order: 'ascending' }">
          <el-table-column prop="brand" label="校区品牌" align="center" v-if="custom.hasP('brand')" width="80">
            <template slot-scope="scope">
              {{ scope.row.brand | dynamicCodeText(brandOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="name" label="校区简称" header-align="center" align="left" v-if="custom.hasP('name')" width="250" />
          <el-table-column prop="province" label="校区省份" align="center" v-if="custom.hasP('province')" width="100" />
          <el-table-column prop="type" label="校区类型" align="center" v-if="custom.hasP('type')" width="80">
            <template slot-scope="scope">
              {{ scope.row.type | dynamicCodeText(campusTypeOptions) }}
            </template>
          </el-table-column>
          <el-table-column prop="status" label="校区状态" align="center" width="80">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.status == 'preparation'" size="mini" key="筹备" type="" effect="dark">
                筹备
              </el-tag>
              <el-tag v-if="scope.row.status == 'normal'" size="mini" key="正常" type="success" effect="dark">
                正常
              </el-tag>
              <el-tag v-else-if="scope.row.status == 'suspended'" size="mini" key="暂停" type="warning" effect="dark">
                暂停
              </el-tag>
              <el-tag v-else-if="scope.row.status == 'close'" size="mini" key="闭校" type="danger" effect="dark">
                闭校
              </el-tag>
              <el-tag size="mini" v-if="scope.row.status == 'expires'" type="info" effect="dark">
                待续费
              </el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="points" label="积分值" sortable="custom" header-align="center" v-if="custom.hasP('points')" width="100">
            <template slot-scope="scope">
              <span style="color: #0eac5c">{{ scope.row.points }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="provinceRanking" label="省排名" sortable="custom" header-align="center" v-if="custom.hasP('provinceRanking')" width="100" />
          <el-table-column prop="ranking" label="全国排名" sortable="custom" header-align="center" v-if="custom.hasP('ranking')" width="100" />
          <el-table-column prop="updateTime" label="最近更新时间" align="center" v-if="custom.hasP('updateTime')" :formatter="custom.tableDateTimeFormat" width="120" />
          <el-table-column label="操作" fixed="right" align="left">
            <template slot-scope="scope">
              <el-button size="small" type="text" @click="addOrUpdateHandle(scope.row.id)" v-has="'btn_operate'">积分操作</el-button>
              <el-button size="small" type="text" @click="logHandle(scope.row.id)" v-has="'btn_record'">积分记录</el-button>
            </template>
          </el-table-column>
        </custom-table>
        <pagination :total="total" :page.sync="listQuery.currentPage" :limit.sync="listQuery.pageSize" @pagination="initData" />
      </div>
    </div>
    <custom-form v-if="formVisible" ref="CustomForm" @refresh="refresh" />
    <log-form v-if="logVisible" ref="LogForm" />
    <batch-integral v-if="batchVisible" ref="batchForm" @refresh="refresh" />
    <import-form v-if="importFormVisible" ref="ImportForm" @refresh="refresh" />
    <export-box v-if="exportBoxVisible" ref="ExportBox" @download="download" />
  </div>
</template>
<script>
export { default } from './index.js'
</script>
